package com.limao.CacheManager;

import com.Hazelcast.Cache;
import com.Hazelcast.CacheFactory;
import com.limao.DBDataClass.CrowdVRUserRmbClass;
import com.limao.DBProvider.CrowdVRUserRmbProvider;
import com.limao.Tool.CacheClass;
import com.limao.cache.BasicModule;

public class CrowdVRUserRmbCache  extends BasicModule{

	private CrowdVRUserRmbProvider provider;
	private static CrowdVRUserRmbCache instance;
	
	public static CrowdVRUserRmbCache getInstance() {
		return instance;
	}

	private Cache<String, CrowdVRUserRmbClass> crowdVRUserRmbCache;

	public CrowdVRUserRmbCache() {
    	super("CrowdVRUserRmbCache");
    	crowdVRUserRmbCache = CacheFactory.createCache("crowd_VRUserRmbCache");
		initProvider();
	}
    
    @Override
	public void initialize() {
        super.initialize();
        instance=this;
    }
	
    public void ClearObjectCache(String userid)
    {
   		crowdVRUserRmbCache.remove(userid);
    } 
  
	
	//&新鲜宝  理财平台  用户资产
	public CrowdVRUserRmbClass Load_CrowdVRUserRmb_Byuserid(String userid)	{
		
		CrowdVRUserRmbClass obj = crowdVRUserRmbCache.get(userid);
		if(obj==null)
		{
			obj = provider.Load_CrowdVRUserRmb_Byuserid(CacheClass.getIntValue(userid));
			if (obj != null)
				crowdVRUserRmbCache.put(userid, obj);
		}

		return obj;
		
	}
	
	

	//**************************************************************************************************/	
	private void initProvider() {
		if (provider == null) {
			try {
				provider = CrowdVRUserRmbProvider.getInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	


}

